<template>
  <el-dialog
    :title="dialogObj.dialogTitle[dialogObj.dialogType]"
    :visible.sync="dialogObj.dialogVisible"
    :close-on-click-modal="false"
    width="60%"
    @close="dialogClose"
  >
    <el-form
      ref="formObj"
      :model="formObj"
      :rules="rules"
      :disabled="dialogObj.dialogType === 'check'"
      label-width="150px"
      :label-position="'left'"
    >
      <el-form-item label="排序号" prop="sortNum">
        <el-input-number
          v-model="formObj.sortNum"
          step-strictly
          :step="1"
          :min="1"
          @blur="changeNum"
        />
      </el-form-item>
      <el-form-item label="分类名称" prop="title">
        <el-input v-model="formObj.title" />
      </el-form-item>
    </el-form>
    <div class="common-btn-box common-jus-end">
      <el-button @click="dialogClose">
        取 消
      </el-button>
      <el-button
        v-if="dialogObj.dialogType !== 'check'"
        type="primary"
        @click="saveInfo()"
      >
        保 存
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'CategoryDialog',
  props: {
    dialogObj: {
      default: () => {},
      type: Object
    },
    rules: {
      default: () => {},
      type: Object
    },
    formObj: {
      default: () => {},
      type: Object
    }
  },
  methods: {
    changeNum() {
      this.$emit('changeNum')
    },
    dialogClose() {
      this.$emit('dialogClose')
    },
    saveInfo() {
      this.$emit('saveInfo')
    }
  }
}
</script>

<style></style>
